import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);

let Layout = require('@views/layout.vue').default;
let Home = require('@views/home.vue').default;
let About = require('@views/about.vue').default;

const router = new VueRouter({
    mode: 'history',
    base: '/vue',
    routes: [
        {
            path: '/',
            name: 'layout',
            redirect: '/home',
            component: Layout,
            children: [
                {
                    path: 'home',
                    name: 'home',
                    component: Home
                },
                {
                    path: 'about',
                    name: 'about',
                    component: About
                }
            ]
        }
    ]
})

// 动态路由加载，会报加载chunk失败。
// vue-router.esm.js?8c4f:2314 ChunkLoadError: Loading chunk about failed
// const router = new VueRouter({
//     mode: 'history',
//     base: '/vue',
//     routes: [
//         {
//             name: 'layout',
//             path: '/',
//             redirect: '/home',
//             component: Layout,
//             children: [
//                 {
//                     path: 'home',
//                     name: 'home',
//                     component: () => import(/* webpackChunkName: "my" */ '@views/home.vue')
//                 },
//                 {
//                     path: 'about',
//                     name: 'about',
//                     component: () => import(/* webpackChunkName: "about" */ '@views/about.vue')
//                 }
//             ]
//         }
//     ]
// })


export default router;
